package com.huawei.userservice.mapper;



import com.huawei.userservice.pojo.entity.User;
import org.apache.ibatis.annotations.*;

@Mapper
public interface UserMapper {
    //1 根据用户名查询用户
    @Select("select * from douyue.user where username=#{username} and status =1")
    User findByUsername(String username);

    //2 添加用户
    @Insert("insert into douyue.user(id,username,password,create_time,update_time,douyue_id) values(#{id},#{username},#{password},now(),now(),#{id})")
    void add(@Param("username") String username,@Param("password") String password,@Param("id") Long id);


    @Update("update douyue.user set phone=#{phone},email=#{email},update_time=now(),nickname=#{nickname},brief=#{brief},gender=#{gender},birthday=#{birthday} where id=#{id}")
    void updateUserInfo(User user);

    @Update("update douyue.user set status=0")
    void deleteUser();


    @Update("update douyue.user set douyue_id=#{douyueId}")
    void updateDyId(String douyueId);

    @Select("select * from douyue.user where douyue_id=#{douyueId}")
    User findByDyId(String douyueId);

    @Update("update douyue.user set money=money+#{money} where id=#{id}")
    void updateMoney(@Param("money") Integer money,@Param("id") Long id);


    @Update("update douyue.user set money=money+#{money} where id=#{setterId}")
    void pay(@Param("setterId") Long setterId,@Param("money") Integer money);
}
